package cg.cmm.alioss.utils;

/**
 * @author: baibing
 * create time: 2024-12-01 22:17
 * description:
 */
public class ResultUtils {

    public static final Boolean SUCCESS_FLAG = Boolean.TRUE;
    public static final String SUCCESS_MSG = "操作成功";
    public static final Boolean FAILURED_FLAG = Boolean.FALSE;


    public static FileResultInfo success(Object object) {
        FileResultInfo resultInfo = new FileResultInfo();
        resultInfo.setIsSuccess(SUCCESS_FLAG);
        resultInfo.setMessage(SUCCESS_MSG);
        resultInfo.setData(object);
        return resultInfo;
    }

    public static FileResultInfo success(String message) {
        FileResultInfo resultInfo = new FileResultInfo();
        resultInfo.setIsSuccess(SUCCESS_FLAG);
        resultInfo.setMessage(message);
        return resultInfo;
    }

    public static FileResultInfo success() {
        return success(SUCCESS_MSG);
    }

    public static FileResultInfo error(FileErrorEnum code, String message) {
        FileResultInfo resultInfo = new FileResultInfo();
        resultInfo.setIsSuccess(FAILURED_FLAG);
        resultInfo.setMessage(message);
        resultInfo.setCode(code.getCode());
        return resultInfo;
    }

    public static FileResultInfo error(String message) {
        return error(FileErrorEnum.COMMON_ERROR, message);
    }
}
